#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <climits>

using namespace std;


class Solution {
public:
	vector<vector<int> > generate(int rowIndex) {
		rowIndex++;
		vector<int> ahead, after;
		vector<vector<int> > answer;
		ahead.resize(1);
		after.resize(2);
		ahead[0] = 1;
		after[0] = 1;
		int k = rowIndex;
		for (int i = 1; i < rowIndex; ++i){
			answer.push_back(ahead);
			for (int j = 0; j < i - 1; ++j){
				after[j + 1] = ahead[j] + ahead[j + 1];
			}
			after[i] = 1;
			ahead = after;
			after.resize(i + 2);
		}
		return answer;
	}
};

int main(int argc, char argv){
	for (auto e : Solution().generate(5)){
		for (auto i : e)
			cout << i << ' ';
		cout << endl;
	}
	return 0;
}